<?php
    session_start();
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $oid = $_REQUEST['oid'];
    $obser = utf8_decode($_REQUEST['obs']);
    $usuario = $_SESSION['usuario'];
    
     if($usuario == ""){
            print_r(json_encode(array('n'=>1)));
     }
        else{
            $inser= "insert into segobservacion(hcnsolexa,segobserva,segfecha,usu_oid)values('".$oid."','".$obser."',GETDATE(),'".$usuario."')";
            $con->query($inser);
            print_r(json_encode(array('n'=>2)));
     }
  /*     $count ="select COUNT(*) as n from segimagenes where hcnsolexa = '".$oid."'";
        $res = $con->query($count);
    
    while($res2 = mssql_fetch_array($res)){
        $n = $res2['n'];
    }
    if ($n == 0){
        if($usuario == ""){
            print_r(json_encode(array('n'=>1)));
        }
        else{
            $inser= "insert into segimagenes(hcnsolexa,segobserva,usu_oidobs,segfecobs)values('".$oid."','".$obser."','".$_SESSION['usuario']."',GETDATE())";
            $con->query($inser);
            print_r(json_encode(array('n'=>2)));
            }
        }
    else {
        if($usuario == ""){
            print_r(json_encode(array('n'=>1)));
        }
        else{
            $update ="update segimagenes
                        set segobserva ='".$obser."',
                        segfecobs = GETDATE(),
                        usu_oidobs ='".$_SESSION['usuario']."'
                      where hcnsolexa ='".$oid."'";
            $con->query($update);
            print_r(json_encode(array('n'=>2)));
        }
   }*/
       
    $con->cerrarConexion();
    
 
?>